module.exports = function (UC, source, config, ArFor, cache, package) {
    var UserControl = UC;

    var source = config.Source;
    var router = function (req, res, next) {
        var body = req.body;
        var key = req.sessionID;
        var email = config.email;
        UserControl.setvalue(key, {});
        new source({
            "SQL": "SELECT db.id FROM [user] as db where db.email='{email}';",
            "type": "row"
        }, {
            email: body.email
        }, function (obj) {
            if (obj) {
                var VerificationCode = parseInt(Math.random() * 9) + '' + parseInt(Math.random() * 9) + '' + parseInt(Math.random() * 9) + '' + parseInt(Math.random() * 9) + '' + parseInt(Math.random() * 9) + '' + parseInt(Math.random() * 9) + '';
                new source({
                        "SQL": "SELECT db.email AS email, db.pass AS pass FROM config AS db where id=1;",
                        "type": "row"
                    },
                    function (db) {
                        db.to = body.email;

                        db.subject = '密码重置';

                        db.view = {
                            id: "JC20FQHAFXR",
                            file: './jviews/email/release.ejs'
                        };
                        db.options = {
                            title: db.subject,
                            VerificationCode: VerificationCode
                        };

                        var _email = new email(db);
                        _email.sendMailView(db, res, function (off, error) {
                            console.log(off)
                            console.log(error)
                            if (off == true) {
                                res.Json({
                                    error: 103
                                });
                            } else {
                                UserControl.SetParamet(key, 'Release', {
                                    id: obj.id,
                                    VerificationCode: VerificationCode
                                });
                                res.Json({
                                    error: 0
                                });
                            }
                        })
                    })
            } else {
                res.Json({
                    error: 103
                });
            }
        })
    }
    return router;

}